﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace Croton.Common.Helper
{
    public class DoubanHelper
    {
        const string DOUBANAPI = "http://api.douban.com//v2/movie/subject/";

        public static Dictionary<string,string> GetTVImagesById(string id)
        {
            using (var httpclient = new HttpClient())
            {
                var body = httpclient.GetStringAsync(DOUBANAPI + id).Result;
                dynamic result = JsonConvert.DeserializeObject<dynamic>(body);

                var dic = new Dictionary<string, string>();
                dic.Add("small", result.images.small.Value);
                dic.Add("large", result.images.large.Value);
                dic.Add("medium", result.images.medium.Value); 
                return dic; 
            } 
        }
    }
}
